Prerequisites
GDAL Scripts requires Python 3.x and the GDAL library with Python bindings. The recommended approach is to use Anaconda, which simplifies GDAL installation and dependency management.Python 2 versions of some scripts exist in the repository for legacy support, but Python 3 is strongly recommended for all new installations.
Installation Steps
Install Anaconda (Recommended)
If you don’t already have Anaconda installed, download it from anaconda.com.Anaconda provides the easiest path to getting GDAL installed with all necessary dependencies.
Install GDAL
GDAL is the core dependency for all scripts in this collection. Install it using conda:This command installs GDAL along with the Python bindings automatically.
Alternative: Install GDAL without Anaconda
Alternative: Install GDAL without Anaconda
If you prefer not to use Anaconda, you can install GDAL via other methods:On Ubuntu/Debian:On macOS with Homebrew:On Windows:
Download OSGeo4W installer from osgeo.org and select GDAL during installation.
Install Additional Python Dependencies
Several scripts require NumPy and SciPy for numerical operations:Or using pip:
Not all scripts require these dependencies. Check individual script README files for specific requirements.
Clone the Repository
Clone the GDAL Scripts repository from GitHub:The scripts are ready to use immediately - no build or install step is required.
Verifying Individual Scripts
Most scripts provide usage information when run without arguments:Common Issues and Troubleshooting
ImportError: No module named 'osgeo'
ImportError: No module named 'osgeo'
This error indicates GDAL Python bindings are not installed or not in your Python path.Solution:
- If using Anaconda:
conda install gdal - If using pip:
pip install gdal - Ensure you’re using the same Python environment where GDAL was installed
ImportError: No module named 'numpy' or 'scipy'
ImportError: No module named 'numpy' or 'scipy'
Some scripts require NumPy and SciPy for array operations and filtering.Solution:orScripts requiring these dependencies include:
gdal_baseline_slope.py(requires both)- Various terrain analysis tools
GDAL version mismatch errors
GDAL version mismatch errors
If you see errors about GDAL version mismatches between the library and Python bindings:Solution with Anaconda (recommended):Solution with pip:This ensures the Python bindings match your GDAL library version.
Permission denied when running scripts
Permission denied when running scripts
Solution:
Make scripts executable:Or always run with Python explicitly:
Scripts run slowly or use too much memory
Scripts run slowly or use too much memory
Some scripts, particularly
gdal_baseline_slope.py, load entire images into memory.Solutions:- Work with smaller regions of interest
- Use 8-bit output (
-ot Byteflag) instead of 32-bit when possible - Increase available system memory
- Process images in tiles for very large datasets
“Current implementation loads full image into memory and is fairly slow.”
Environment Setup Tips
Creating a Dedicated Conda Environment
For cleaner dependency management, create a dedicated environment:Adding Scripts to Your PATH
To run scripts from anywhere without specifying full paths:~/.bashrc or ~/.zshrc to make it permanent.
System Requirements
Minimum Requirements
- Python 3.6+
- GDAL 2.0+
- 4GB RAM (for small images)
- Any major OS (Linux, macOS, Windows)
Recommended
- Python 3.9+
- GDAL 3.0+
- 16GB+ RAM (for large planetary datasets)
- SSD storage for faster I/O
Next Steps
Quick Start Guide
Now that you have GDAL Scripts installed, try out some practical examples